import request from '@/utils/request'

enum Api{
  // 获取spulist列表
  getSpuListApi = '/admin/product',
  // 添加spuInfo数据
  saveSpuInfoApi = '/admin/product/saveSpuInfo',
  // 更新spuInfo数据
  updateSpuInfoApi = '/admin/product/updateSpuInfo',
  // 删除spuInfo数据
  deleteSpuInfoApi = '/admin/product/deleteSpu',
  // 所有销售属性
  baseSaleAttrListApi = '/admin/product/baseSaleAttrList',
  // 所有品牌列表数据
  trademarkListApi = '/admin/product/baseTrademark/getTrademarkList',
  // 根据spuId获取对应图片列表
  getSpuImageListApi = '/admin/product/spuImageList',
  // 根据spuId获取销售属性列表
  getSpuSaleAttrListApi = '/admin/product/spuSaleAttrList'
}

// 获取spu列表数据的接口函数
export const reqGetSpuListData = (page: number, limit:number, category3Id: number)=>{
  return request.get(Api.getSpuListApi + `/${page}/${limit}?category3Id=` + category3Id)
}
// 获取所有品牌列表的接口函数
export const reqGetAllTrademarkListData = ()=>{
  return request.get(Api.trademarkListApi)
}
// 获取所有销售属性的接口函数
export const reqGetAllBaseSaleAttrListData= ()=>{
  return request.get(Api.baseSaleAttrListApi)
}
// 添加spuInfo的接口函数
export const reqSaveSpuInfoData = (spuInfo)=>{
  return request.post(Api.saveSpuInfoApi,spuInfo)
}
// 删除spuInfo的接口函数
export const reqDeleteSpuInfo = (spuId: number)=>{
  return request.delete(Api.deleteSpuInfoApi + `/${spuId}`)
}
// 根据spuId获取图片列表
export const reqGetSpuImageListData = (spuId: number)=>{
  return request.get(Api.getSpuImageListApi + `/${spuId}`)
}
// 根据spuId获取基本销售属性
export const reqGetSpuSaleAttrListData = (spuId: number)=>{
  return request.get(Api.getSpuSaleAttrListApi + `/${spuId}`)
}
// 更新spuInfo数据
export const reqUpdateSpuInfoApi = (spuInfo) =>{
  return request.post(Api.updateSpuInfoApi, spuInfo)
}